package spider.util;

import spider.NovelSiteEnum;
import spider.impl.chapter.BxwxChapterSpider;
import spider.impl.chapter.DefaultChapterSpider;
import spider.interfaces.IChapterSpider;

/**
 * 工厂类,获得  novel.spider.interfaces.IChapterSpider 接口的实现类
 * created by yb
 * on 2017/8/11.
 **/
public final class ChapterSpiderFactory {
    private ChapterSpiderFactory() {
    }

    /**
     * 通过给定的url   返回实现了IChapterSpider的实现类
     * @param url 网页列表的url
     * @return 实现类
     */
    public static IChapterSpider GetChapterSpider( String url){
        NovelSiteEnum novelSiteEnum = NovelSiteEnum.getNovelSiteEnumByUrl(url);
        IChapterSpider chapterSpider = null;
        switch (novelSiteEnum){
            case BiXiaWenXue:{
                chapterSpider = new BxwxChapterSpider();
                break;
            }
            case KanShuZhong:
            case BiQuGe:
            case DingDianXiaoShuo:{
                chapterSpider = new DefaultChapterSpider();
                break;
            }
        }
        return chapterSpider;
    }
}
